local STRINGS = GLOBAL.STRINGS
local Ingredient = GLOBAL.Ingredient
local TECH = GLOBAL.TECH
local Formula_Coefficient = GetModConfigData("Formula_Coefficient")
local Fresh_Keeping_Coefficient = GetModConfigData("Fresh_Keeping_Coefficient")

STRINGS.RECIPE_DESC.KRAMPUS_SACK = "携带更多的东西且不会减速！！"

-- 小偷包保鲜机制
local function cool(inst)
    if not inst.components.preserver then
        inst:AddComponent("preserver")
    end
    if Fresh_Keeping_Coefficient == "1" then -- 保鲜
        inst.components.preserver:SetPerishRateMultiplier(0.5)
    elseif Fresh_Keeping_Coefficient == "2" then -- 反鲜
        inst.components.preserver:SetPerishRateMultiplier(-0.01)
    end
end
-- 初始化配方
function FormulaInit()
    local formula = {} -- 配方
    if Formula_Coefficient == "1" then
        -- 材料:熊皮1、电子元件2、齿轮2、牛毛10
        formula = {
            Ingredient("bearger_fur", 1),
            Ingredient("transistor", 2),
            Ingredient("gears", 2),
            Ingredient("beefalowool", 10)
        }
    elseif Formula_Coefficient == "2" then
        -- 材料:熊皮1、电子元件2、齿轮2、海象牙1、格罗姆黏液4、月熠10
        formula = {
            Ingredient("bearger_fur", 1),
            Ingredient("transistor", 2),
            Ingredient("gears", 2),
            Ingredient("walrus_tusk", 1),
            Ingredient("glommerfuel", 4),
            Ingredient("moonstorm_spark", 10)
        }
    end
    AddRecipe2("krampus_sack", formula, TECH.SCIENCE_TWO, nil, {"CONTAINERS"})
end

-- 初始化
function init()
    -- 如果开启配方
    if Formula_Coefficient ~= "0" then
        FormulaInit()
    end
    -- 如果开启保鲜
    if Fresh_Keeping_Coefficient ~= "0" then
        AddPrefabPostInit("krampus_sack", cool)
    end
end

init()
